//
//  MVP-http.m
//  DesignPattern
//
//  Created by jun on 2021/4/16.
//

#import "MVP_http.h"
#import "MVP_httpProtocol.h"

@interface MVP_http ()

@property (nonatomic,weak) id<MVP_httpProtocol> httpProtocol;

@end

@implementation MVP_http

-(instancetype)initWithRequestPotocol:(id<MVP_httpProtocol>)httpProtocol{
    if (self = [super init]) {
        _httpProtocol = httpProtocol;
    }
    return self;
}

-(NSURLRequest *)netGetURL:(NSString *)url params:(NSDictionary *)params{
//    if (1) {
        if ([_httpProtocol respondsToSelector:@selector(onSeccuss:)]) {
            [_httpProtocol onSeccuss:@{@"data":@{@"title":@"title",@"desc":@"desc"}}];
        }
//    }else{
//        if ([_httpProtocol respondsToSelector:@selector(onFail:errCode:errInfo:)]) {
//            [_httpProtocol onFail:nil errCode:-1 errInfo:@"error"];
//        }
//    }
    return [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
}
@end
